<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <meta charset="UTF-8">
		<title>项目信息</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
	    <meta name="author" content="GeeksLabs">
	    <meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
	    <link rel="shortcut icon" href="img/favicon.png">
	
	    <title>Creative - Bootstrap Admin Template</title>
 
  </head>
  
  <body >
    	<c:import url="admin_home.jsp"></c:import>
     	
     	<div class="layui-body container" style="margin-top: 100px">
     		<div class="layui-row" >
     			<form class="layui-form" action="#">
     				<div class="layui-form-item">
					      <div class="layui-input-inline layui-col-md-offset2 layui-col-md4">
					     	<input type="text" id="projectName" name="projectName" lay-verify="required" placeholder="输入项目名称" autocomplete="off" class="layui-input">
					      </div>
					      <div class="layui-col-md4">
					      	<button type="button" class="btn btn-info">查询</button>
					      </div>
					 </div>
				</form>
     			
     		</div>
     	<!-- 显示表格数据 -->
		
     		<div class="layui-row layui-col-space10" style="margin-top: 20px" id="infoBody">
     			<!--  
	     		<div class="col-md-5 col-md-offset-2">
	     			<div class="panel panel-default">
					  <div class="panel-heading">
					    <h3 class="panel-title">创新创业中心管理平台<small>&nbsp;&nbsp;进度:<mark>申报成功</mark></small></h3>
					  </div>
					  <div class="panel-body">
					    <p class="text-left">项目简介:
					    <textarea class="form-control" rows="4">Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur.Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.
					    </textarea>
					    </p>
					  </div>
					  
					  <ul class="list-group">
					    <li class="list-group-item">
					    	项目组长:&nbsp;&nbsp;张三(教师)&nbsp;&nbsp;
					    </li>
					    <li class="list-group-item">项目成员:&nbsp;&nbsp;张思,张武,张六,张琪</li>
					    <li class="list-group-item">使用房间:&nbsp;&nbsp;#2号楼306</li>
					    <li class="list-group-item">
					    	项目申报书:<a href="#">下载</a>&nbsp;&nbsp;
					    	需求分析报告:<a href="#">下载</a>&nbsp;&nbsp;
					    	项目报告:<a href="#">下载</a>
					    </li>
					    <li class="list-group-item">
							立项时间:&nbsp;&nbsp;2018-3-2&nbsp;&nbsp;
							预计完成时间:&nbsp;&nbsp;2018-5-10</li>
					    
					  </ul>
					</div>
	     		<div class="col-md-5">
	     			<div class="panel panel-default">
					  <div class="panel-heading">
					    <h3 class="panel-title">卓越班导师选报系统<small>进度:<mark>验收完成</mark></small></h3>
					  </div>
					  <div class="panel-body">
					    <p class="text-left">项目简介:</p>
					    <p>Some default panel content here. Nulla vitae elit libero, 
					    a pharetra augue. Aenean lacinia bibendum nulla sed consectetur.
					     Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. 
					     Nullam id dolor id nibh ultricies vehicula ut id elit.
					    </p>
					  </div>
					  
					  <ul class="list-group">
					    <li class="list-group-item">Cras justo odio</li>
					    <li class="list-group-item">Dapibus ac facilisis in</li>
					    <li class="list-group-item">Morbi leo risus</li>
					    <li class="list-group-item">Porta ac consectetur ac</li>
					    <li class="list-group-item">Vestibulum at eros</li>
					  </ul>
					  </div>
				</div>
				</div>
	     	</div>
	     	-->
	     	</div>
     		<div class="layui-row">
     			<div class="layui-col-md-offset1 layui-col-md3" id="page_info_area">
     			</div>
     			<div class="col-md-5" id="page_info_nav">
     			</div>
     		</div>
     	</div>
     	
		<script type="text/javascript">
		
		
	    $(function(){
	    	toPage(1);
	    });
	    function toPage(pn){
	    	$.ajax({
	    		url:"${pageContext.request.contextPath}/admin/getProjectInfo.do",
	    		data:"pageNum="+pn,
	    		type:"GET",
	    		success:function(result){
	    			console.log(result);
	    			//1.解析并显示数据
	    			build_tableInfo(result);
	    			//2.解析显示分页信息
	    			build_pageInfo(result);
	    			build_page_nav(result);
	    			
	    		}
	    	});
	    }
	    
	    //解析显示分页信息
	    function build_tableInfo(result){
	    	$("#infoBody").empty();
	    	var projectInfo=result.extend.page.list;
	    	$.each(projectInfo,function(index,pro){
			    var status="验收完成";
	    		if(pro.project.projectStatus==1){
	    			status="申报成功";
	    		}else if(pro.project.projectStatus==2){
	    			status="已提交需求";
	    		}else if(pro.project.projectStatus==3){
	    			status="开始编码";
	    		}else if(pro.project.projectStatus==4){
	    			status="编码完成20%";
	    		}else if(pro.project.projectStatus==5){
	    			status="编码完成40%";
	    		}else if(pro.project.projectStatus==6){
	    			status="编码完成60%";
	    		}else if(pro.project.projectStatus==7){
	    			status="编码完成80%";
	    		}else if(pro.project.projectStatus==8){
	    			status="已完成编码";
	    		}else if(pro.project.projectStatus==9){
	    			status="测试阶段";
	    		}else if(pro.project.projectStatus==10){
	    			status="申请验收";
	    		}
			    var head=$("<div></div>").addClass("panel-heading").append();
			    var head_h=$("<h3></h3>").addClass("panel-title").append(pro.project.projectName).append($("<small></small>").append("&nbsp;&nbsp&nbsp;&nbsp进度:&nbsp;&nbsp")
	    					.append($("<mark></mark>").append(status)));
			    head.append(head_h);
			  	var body=$("<div></div>").addClass("panel-body").append($("<p></p>").addClass("text-left").append("项目简介:").append($("<textarea></textarea>")
			  			.addClass("form-control").attr("rows","4").append(pro.project.projectInfo)));
			  	var li1=$("<li></li>").addClass("list-group-item").append("项目组长:&nbsp;&nbsp;"+pro.group.leaderName);
			  	var li2=$("<li></li>").addClass("list-group-item").append("项目成员:&nbsp;&nbsp;");
			  	if(pro.members==null||pro.members.length==0){
			  		li2.append("无");
			  	}else{
			  		$.each(pro.members,function(index,member){
				  		li2.append(member.stuName+",");
				  	});
			  	}
			  	
			  	var li3=$("<li></li>").addClass("list-group-item")
			  		.append("使用房间:&nbsp;&nbsp;").append(pro.project.roomId);
			  	
			  	var report1=$("<a></a>").attr("href","${pageContext.request.contextPath}/file/downloadProjectFile.do?fileId="+pro.project.declareReport).append("下载&nbsp;&nbsp;");
			  	var report2=$("<a></a>").attr("href","${pageContext.request.contextPath}/file/downloadProjectFile.do?fileId="+pro.project.analyseReport).append("下载&nbsp;&nbsp;");
			  	var report3=$("<a></a>").attr("href","${pageContext.request.contextPath}/file/downloadProjectFile.do?fileId="+pro.project.projectReport).append("下载&nbsp;&nbsp;");
			  	var li4=$("<li></li>").addClass("list-group-item");
			  	if(pro.project.declareReport==null){
			  		li4.append("项目申报书:").append("未上传&nbsp;&nbsp;");
			  	}else{
			  		li4.append("项目申报书:").append(report1);
			  	}
			  	if(pro.project.analyseReport==null){
			  		li4.append("需求分析报告:").append("未上传&nbsp;&nbsp;");
			  	}else{
			  		li4.append("需求分析报告:").append(report2);
			  	}
			  	if(pro.project.projectReport==null){
			  		li4.append("项目报告:").append("未上传");
			  	}else{
			  		li4.append("项目报告:").append(report3);
			  	}
			  	var li5=$("<li></li>").addClass("list-group-item")
			  		.append("立项时间:&nbsp;&nbsp;"+pro.project.createTime);
			  		
			  	if(pro.project.update_finishTime==null){
			  		li5.append("&nbsp;&nbsp;预计完成时间:&nbsp;&nbsp;"+pro.project.finishTime);
			  	}else{
			  		li5.append("&nbsp;&nbsp;预计完成时间:&nbsp;&nbsp;"+pro.project.update_finishTime);
			  	}
	    	
			  	var li6=$("<li></li>").addClass("list-group-item"); 
			  	if(pro.checkProject!=null&&pro.checkProject.applyStatus==2){
			  		li6.append("评分:&nbsp;&nbsp").attr("id",pro.checkProject.projectId);
			  		show_rate(li6,pro.checkProject.pro_rate);
			  		li6.css("width","300px");
			  	}else if(pro.checkProject!=null&&pro.checkProject.applyStatus==3){
			  		li6.append("驳回原因:&nbsp;&nbsp").append(pro.checkProject.failCheckInfo);;
			  	}
			  	var list=$("<ul></ul>").addClass("list-group")
			  		.append(li1).append(li2).append(li3).append(li4).append(li5).append(li6);
     			if(index==0){
     				$("<div></div>").addClass("layui-col-md-offset1 layui-col-md5 ").append($("<div></div>").addClass("panel panel-default")
     						.append(head).append(body).append(list)).appendTo("#infoBody");
     			}else{
     				$("<div></div>").addClass("layui-col-md5").append($("<div></div>").addClass("panel panel-default")
     						.append(head).append(body).append(list)).appendTo("#infoBody");
     			}
	    	});
	    }
	    //加载评分
	    function show_rate(obj,num) {
	    	obj.raty({ 
	    		path:'${pageContext.request.contextPath}/img/star',
	    		readOnly: true,
	    		score:num 
	    	});
		}
	  
	    
	    function showProjectInfo(info){
	    	
	    	layer.alert();
	    }
	    //解析显示分页信息
	    var currentPage;
	    function build_pageInfo(result){
	    	$("#page_info_area").empty();
	    	currentPage=result.extend.page.pageNum;
	    	$("#page_info_area").append("当前"+result.extend.page.pageNum+"页，共"+result.extend.page.pages+"页,一共"+result.extend.page.total+"条记录");
	    	totalRecord=result.extend.page.total;
	    }
	    
	    function build_page_nav(result){
	    	$("#page_info_nav").empty();
	    	var ul=$("<ul></ul>").addClass("pagination");
	    	var firstPage=$("<li></li>").append($("<a></a>").append("首页").attr("href","#"));
	    	var prePage=$("<li></li>").append($("<a></a>").append("上一页"));
			if(result.extend.page.hasPreviousPage==false){
				firstPage.addClass("disabled");  
				prePage.addClass("prePage");
	    	}
			firstPage.click(function(){
				toPage(1);
			});
			prePage.click(function(){
				if(result.extend.page.pageNum==1){
					toPage(1);
				}else{
					toPage(result.extend.page.pageNum-1);
				}
				
			});
	    	var nextPage=$("<li></li>").append($("<a></a>").append("下一页"));
	    	var lastPage=$("<li></li>").append($("<a></a>").append("尾页").attr("href","#"));
	    	if(result.extend.page.hasNextPage==false){
	    		nextPage.addClass("disabled");  
	    		lastPage.addClass("prePage");
	    	}
	    	lastPage.click(function(){
				toPage(result.extend.page.pages);
			});
	    	nextPage.click(function(){
	    		if(result.extend.page.pageNum==result.extend.page.pages){
	    			toPage(result.extend.page.pages);
	    		}else{
	    			toPage(result.extend.page.pageNum+1);
	    		}
				
			});
	    	ul.append(firstPage).append(prePage);
	    	$.each(result.extend.page.navigatepageNums,function(index,item){
	    		var numLi=$("<li></li>").append($("<a></a>").append(item));
	    		if(result.extend.page.pageNum==item){
	    			numLi.addClass("active");
	    		}
	    		numLi.click(function(){
	    			toPage(item);
	    		});
	    		ul.append(numLi);
	    	});
	    	ul.append(nextPage).append(lastPage);
	    	var navElv=$("<nv></nv>").append(ul);
	    	navElv.appendTo("#page_info_nav");
	    }
	   
	    
		//layui
		layui.use('form', function(){
		  var form = layui.form;
		  
		});
		
		
	  </script>
  </body>
</html>
